#ifndef OCTASK_H_INCLUDED
#define OCTASK_H_INCLUDED

#include <glib.h>
#include "ockvpair.h"

typedef enum _oc_bool
{
    OC_MAP_TASK = 0,
    OC_MERGE_TASK = 1
}oc_task_type_t;

typedef struct
{
    //gpointer                *data;
    GArray                  *data_array;
    guint32                 granularity;
    oc_task_type_t          type;
}oc_task_t;

static inline
void oc_task_init ( oc_task_t               *task,
                    guint32                 granularity,
                    oc_task_type_t          type        )
{
    guint32 data_size = 0;
    switch ( type )
    {
        case OC_MAP_TASK:
        data_size = sizeof ( oc_key_val_pair_t );
        break;

        case OC_MERGE_TASK:
        break;
    }

    task->data_array = g_array_sized_new (   FALSE,
                                            FALSE,
                                            data_size,
                                            granularity );
    //task->data_array = g_malloc ( data_size * granularity );
    task->granularity = granularity;
    task->type = type;
/*
    guint32 i;
    for ( i = 0; i < granularity; ++i )
    {
        g_array_append_vals ( task->data_array,
                                g_new( oc_task_t, 1 ),
                                1                       );
    }*/
}

static inline
void oc_task_add_data (  oc_task_t               *task,
                         gpointer                 data )
{
    g_array_append_vals ( task->data_array,
                                data,
                                1                       );
}

static inline
void oc_task_destroy (  oc_task_t               *task    )
{
    g_array_free ( task->data_array, TRUE );
}



#endif // OCTASK_H_INCLUDED
